package com.haydn.practice.restfulweb.mBean;

/**
 * @Author haydn
 * @create 2020/8/27 0:27
 * 为了测试、理解JMX功能，自定义MBean
 */
public class Hello implements HelloMBean {

    private String hometown;
    private int age;

    /**
     * 三个构造方法
     */
    public Hello(){
        System.out.println("无参构造方法被调用！");
    }
    public Hello(String hometown){
        System.out.println("hometown 构造方法被调用！");
        this.hometown = hometown;
    }
    public Hello(String hometown, int age){
        System.out.println("hometown , age 构造方法被调用！");
        this.hometown = hometown;
        this.age = age;
    }

    /**
     * 第一个属性Greeting的getter/setter方法，以及print方法--标记被修改、调用
     * @return
     */
    public String getHometown() {
        System.out.println("getHometown 方法被调用！");
        return hometown;
    }

    public void setHometown(String hometown) {
        System.out.println("setHometown 方法被调用！");
        this.hometown = hometown;
    }

    public void printHometown() {
        System.out.println("Print hometown : " + hometown);
    }

    /**
     * 第二个属性age的getter/setter方法，以及print方法--标记被修改、调用
     * @return
     */
    public int getAge() {
        System.out.println("getAge 方法被调用！");
        return age;
    }

    public void setAge(int age) {
        System.out.println("setAge 方法被调用！");
        this.age = age;
    }

    public void printAge() {
        System.out.println("Print age: " + age);
    }
}
